﻿var myApp = angular.module("Lsk", ['ui.bootstrap', 'ngRoute', 'ngSanitize', 'angular-loading-bar', 'ngTable', 'imageupload', 'LocalStorageModule', 'ngMap', 'frapontillo.bootstrap-switch', 'ngResource', 'updateMeta', 'djds4rce.angular-socialshare', 'mega-menu','jkuri.gallery']);

myApp.config(function ($routeProvider, $locationProvider) {
    $locationProvider.html5Mode(true).hashPrefix('!');
    $routeProvider
        .when('/Home', {
            title: '',
            templateUrl: 'view/Home.html',
           
        })
        .when('/AboutUs', {
            title: 'About Us',
            templateUrl: 'view/AboutUs.html'
        })
         .when('/HomeLoanCalculator', {
             title: 'Home Loan Calculator',
             templateUrl: 'view/HomeLoanCalculator.html',
             controller: 'homeLoanCalculatorController'
         })

         .when('/News', {
             title: 'Property News',
             templateUrl: 'view/News.html',
             controller: 'newsController'
         })

         .when('/Events', {
             title: 'Property Events',
             templateUrl: 'view/Events.html',
             controller: 'eventsController'
         })

        .when('/EventDetail/:id', {
            title: 'Events Detail',
            templateUrl: 'view/EventDetail.html',
            controller: 'eventDetailController'
        })

         .when('/UsefulInfo', {
             title: 'Userful Info',
             templateUrl: 'view/UsefulInfo.html',
             controller: 'UsefulInfoController'
         })

         .when('/UsefulInfoDetail/:id', {
             title: 'Userful Info',
             templateUrl: 'view/UsefulInfoDetail.html',
             controller: 'UsefulInfoDetailController'
         })


        .when('/ListingEntry/:id?', {
            title: 'Listing Entry',
            templateUrl: 'view/ListingEntry.html',
            controller: 'listEntryController'
        })

        .when('/NewDetail/:id', {
            title: 'News Detail',
            templateUrl: 'view/NewDetail.html',
            controller: 'newsDetailController'
        })

        .when('/Rpgt', {
            title: 'News Rpgt',
            templateUrl: 'view/Rpgt.html',
            controller: 'rpgtController'
        })
         .when('/Lawyerfee', {
             title: 'Lawyer Fee',
             templateUrl: 'view/Lawyerfee.html',
             controller: 'lawyerfeeController'
         })

         .when('/StampDuty', {
             title: 'Stamp Duty',
             templateUrl: 'view/StampDuty.html',
             controller: 'stampDutyController'
         })
        .when('/PropertySearch', {
            title: 'Search Property',
            templateUrl: 'view/PropertySearch.html',
            controller: 'propertySearchController'
        })
         .when('/Property/:id?/:listType?', {
             title: 'Property Detail',
             templateUrl: 'view/Property.html',
             controller: 'propertyController'
         })
        .when('/PropertyDirectory', {
            title: 'Property Directory',
            templateUrl: 'view/PropertyDirectory.html',
            controller: 'propertyDirectoryController'
        })
        .when('/PropertyDirectoryDetail/:id', {
            title: 'Property Directory',
            templateUrl: 'view/PropertyDirectoryDetail.html',
            controller: 'PropertyDirectoryDetailController'
        })
        .when('/PropertyNew', {
            title: 'Property News',
            templateUrl: 'view/PropertyNew.html',
            controller: 'propertyNewController'
        })
        .when('/PropertyNewDetail/:id', {
            title: 'Property News',
            templateUrl: 'view/PropertyNewDetail.html',
            controller: 'PropertyNewDetailController'
        })
        .when('/Login', {
            title: 'Login',
            templateUrl: 'view/Login.html',
            //controller: 'listEntryController'
            controller: 'loginController'
        })

         .when('/Register', {
             title: 'Register',
             templateUrl: 'view/Register.html',
             controller: 'registerController'
         })
         .when('/Auction', {
             title: 'Auction',
             templateUrl: 'view/Auction.html',
             controller: 'auctionController'
         })
        .when('/AuctionDetail/:id', {
            title: 'Auction Detail',
            templateUrl: 'view/AuctionDetail.html',
            controller: 'auctionDetailController'
        })
        .when('/BuyRent', {
            title: 'Looking For Property To Rent Or Buy',
            templateUrl: 'view/BuyRent.html',
            controller: 'BuyRentController'
        })
         .when('/SaleLet', {
             title: 'Property to Let',
             templateUrl: 'view/SaleLet.html',
             controller: 'SaleLetController'
         })
        .when('/RecentTransaction', {
            title: 'Recent Transaction',
            templateUrl: 'view/RecentTransaction.html',
            controller: 'recentTransactionController'
        })
        .when('/ForgetPassword', {
            title: 'Forget Password',
            templateUrl: 'view/ForgotPassword.html',
            controller: 'ForgetPasswordController'
        })
        .when('/Career', {
            title: 'Join Us Now',
            templateUrl: 'view/Career.html',
            controller: 'CareerController'
        })
        .when('/Tenancy', {
            title: 'Tenancy Agreement Calculator',
            templateUrl: 'view/Tenancy.html',
            controller: 'TenancyController'
        })
         .when('/BestBuy', {
             title: 'Best Buy',
             templateUrl: 'view/BestBuy.html',
             controller: 'BestBuyController'
         })
         .when('/Gallery', {
             title: 'Gallery',
             templateUrl: 'view/Gallery.html',
             controller: 'GalleryController'
         })
         .when('/Agents', {
             title: 'Agents',
             templateUrl: 'view/Agents.html',
             controller: 'AgentsController'
         })
         .when('/Agent/:id', {
             title: 'Agent',
             templateUrl: 'view/Agent.html',
             controller: 'AgentController'
         })
         .when('/Agent/:id/Sale', {
             title: 'Agent',
             templateUrl: 'view/Agent.html',
             controller: 'AgentController'
         })
         .when('/Agent/:id/Rent', {
             title: 'Agent',
             templateUrl: 'view/Agent_Rent.html',
             controller: 'AgentController'
         })
         .when('/Properties/:id/:id2', {
             title: 'Properties',
             templateUrl: 'view/Properties.html',
             controller: 'PropertiesController'
         })
         .when('/NewListing/:id?', {
             title: 'New Listing Properties',
             templateUrl: 'view/NewListing.html',
             controller: 'NewListingController'
         })
         .when('/RoiCalculator', {
             title: 'ROI Calculator',
             templateUrl: 'view/CalcRoi.html',
             controller: 'CalcRoiController'
         })
         .when('/ConversionCalculator', {
             title: 'Conversion Calculator',
             templateUrl: 'view/CalcConvert.html',
             controller: 'CalcConvertController'
         })
         .when('/LoanCheckerCalculator', {
             title: 'Loan Checker Calculator',
             templateUrl: 'view/CalcLoanChecker.html',
             controller: 'CalcLoanCheckerController'
         })
        .otherwise({
            title: 'Home',
            redirectTo: '/Home'
        });



});

myApp.run(['authService', '$rootScope', function (authService, $rootScope) {

    authService.fillAuthData();

    $rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
        if (typeof (current["$$route"]) !== "undefined")
            $rootScope.title = current.$$route.title;

        // Control the Menu to show on other pages while hide on home page
        if (current.$$route.originalPath == "/Home") {
            $rootScope.$emit('NavHomePage');
        } else {
            $rootScope.$emit('NavOtherPage');
        }
    });
}])

myApp.run(function ($FB) {
    $FB.init('720197931447724');
    //720197931447724 - www.penangrealty.my
    //367786686613740 - localhost
})

//myApp.run(function ($rootScope, NgMap) {
//    NgMap.getMap().then(function (map) {
//        $rootScope.map = map;
//    });
//});

myApp.config(function ($httpProvider) {
    $httpProvider.interceptors.push('authInterceptorService');
});


// your overall app controller
myApp.controller("AppController", function AppController($scope) {
    $scope.metadata = {
        'title': 'Penang Realty 世界地產',
        'description': 'Penang Realty - Northern Malaysia real estate one stop center provides complete solution on property. We provide sale & rent service, market information, transaction price, property market analysis and many more...',
    };

    // whenever a controller emits the newPageLoaded event, we update the app's metadata
    $scope.$on('newPageLoaded', function (event, metadata) {
        $scope.metadata = metadata
        window.prerenderReady = true;
    });

})
